<template>
	<view class="content" v-show="show">
		<!-- 头部导航 -->
		<view class="w-750 w-bj-cont" style="position: fixed; top: 0; left: 0;">
			<view class="h-100 w-row-justify-between-align">
				<view class="wh-80 w-row-center" @click="routerBack()">
					<image class="wh-40" src="../../../static/gane/fh.png"></image>
				</view>
				<view class="w-250 h-100 w-row-center w-wz-conts font-36">存款管理</view>
				<view class="wh-80">

				</view>
			</view>
		</view>
		<view class="bwh-100"></view>
		<!-- 头部导航结束 -->
		<view class="bwh-20"></view>
		<!-- 内容区域 -->

		<view class="w-720 w-bj-cont w-bor-12 w-column-align">
			<view class="wh-20"></view>
			<view class="w-680 h-260 w-relative">
				<image class="w-680 h-260 w-bor-12" src="../../../static/gane/wiial.png"></image>
				<view class="w-680 h-260 w-absolute-left font-36b w-col-center w-bor-12">
					<view class="w-600 h-60 ">
						<view class="w-wz-white">余额：<text class="w-wz-gree">￥{{money}}</text></view>
					</view>
					<view class="w-600 h-60 ">
						<view class="w-wz-white">昵称：<text>{{nickname}}</text></view>
					</view>

				</view>
			</view>
			<view class="wh-50"></view>
			<view class="w-620 h-160 w-column-justify-around-align w-wz-red font-32 p-20 w-bor-12"
				style="border: solid 2rpx #5b5b5b;">
				<text style="color: gold;">尊敬会员你好，充值通道在维护中！</text>
				<text>请勿擅自转账，以免造成资金损失！</text>
				<text style="color: aqua;">存款前请联系，客服获取充值方式！</text>
			</view>

			<view class="wh-50"></view>
			<input v-model="amoney"
				style="width: 610rpx; border: solid 2rpx #ccb581; padding: 20rpx; border-radius: 12rpx; color: #ffffff;"
				type="number" placeholder="请输入金额" placeholder-class="w-wz-conts">
			<view class="wh-50"></view>
			<button style="width: 650rpx; background-color: #ccb581;" @click="submitForm()">提交</button>
			<view class="wh-50"></view>
            <view class="w-200 w-row-center" @click="RouteIndex()">
            	<image class="wh-40" src="../../../static/gane/czjl.png"></image>
            	<view class="h-80 w-row-center w-wz-conts font-32 m-left-2 m-bottom-6">存款记录</view>
            </view>
			<view class="wh-100"></view>
		</view>

	</view>
</template>

<script>
	import $H from '@/pages/common/request.js'
	export default {
		data() {
			return {
				UserInfo: {},
				show: false,
				money: null,
				nickname: null,
				amoney: ''
			}
		},

		onLoad() {

			this.UserInfo = uni.getStorageSync('UserInfo');
			if (this.UserInfo.uid && this.UserInfo.token) {
				this.getMoney()
			} else {
				return uni.reLaunch({
					url: '/pages/index/index'
				});
			}


		},

		methods: {

			submitForm() {
				
				if (Number(this.amoney < 1)) {
					return uni.showToast({
						title: '存款金额不能为空',
						duration: 1000,
						icon: 'none'
					});
				}

				let then = this
				uni.showModal({
					title: '存款提示',
					content: '存款前请先联系客服,询问存款方式',
					cancelText: '联系客服',
					confirmText: '确定充值',
					success: function(res) {
						if (res.confirm) {
							$H.post('/app_user_wallet', {
								type: 'save',
								amoney: then.amoney
							}).then((res) => {
								console.log(res)
								if (res.code == 200) {
									setTimeout(()=>{
										this.routerBack()
									}, 2000)
									return uni.showToast({
										title: res.msg,
										duration: 2000,
										icon: 'none'
									});
								}
							})
						} else if (res.cancel) {

						}
					}
				});
			},

			getMoney() {
				$H.post('/app_user_money').then((res) => {
					console.log(res)
					if (res.code == 200) {
						this.show = true
						this.money = res.data.money
						this.nickname = res.data.nickname
					} else {
						uni.clearStorageSync()
						uni.reLaunch({
							url: '/pages/index/index'
						});
						return uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
			},
			
			RouteIndex() {
				uni.navigateTo({
					url: '/pages/my/wallet/save_money_log'
				});
			},

			

		}
	}
</script>

<style>

</style>
